package io.File;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;

public class Demo {
    public static void main(String[] args) throws IOException {
        //一次读取24个字符
        File file = new File("D:\\test\\MyStringTest.java");
        FileInputStream stream = new FileInputStream(file);
        byte[] buff= new byte[24];
        int len = stream.read(buff);
        while ((len=stream.read(buff))!=-1){
            System.out.println(len);
            System.out.println(Arrays.toString(buff));
        }
    }
    private static void test1() throws IOException {
        File file = new File("D:\\test\\MyStringTest.java");
        //操作
        FileInputStream stream = new FileInputStream(file);
        //一次读一个
        int read;
        while ((read = stream.read())!=-1){
            System.out.println(read);
        }
    }
}
